// Texas A&M University          //
// cpsc321 Computer Architecture //
// $Id: signextend.v,v 1.1 2001/11/07 19:25:23 miket Exp miket $ //
// A insize->outsize sign extender //
module Extender(SignExt,in, out);
   parameter INSIZE = 16, OUTSIZE = 32;

   input SignExt;
   input [INSIZE-1:0] in;
   output [OUTSIZE-1:0] out;
	 reg [OUTSIZE-1:0] out;
	 always@(SignExt or in)
	    if(SignExt)
          out = {{ OUTSIZE-INSIZE {in[INSIZE-1]}}, in};
			else
			    out = in;	 

endmodule // Extender

/*
module TestExtender;

   reg SignExt;
	 reg [15:0] in;
	 wire [31:0] out;


   Extender TestExt(SignExt,in,out);

	 initial begin

	 $monitor($time, "Signext = %d, in=%b,out=%b",SignExt,in,out);

	 SignExt = 0;
	 in = 0;
#10 in = 45;
#10 SignExt = 1;
#10 in = -4; 
#10 $finish;

	 end

	 endmodule
	 */
